ifeq ($(strip $(targetbase)),linux)
include $(MK_DIR)/sys.mk

OBJ_DIR=$(OBJ_BASE_DIR)/core

LIB = sdkcore
SRCS = $(shell find api/src -name "*.c")
ifneq ($(ASW_ALONE), yes)
SRCS += $(shell find common/src -name "*.c")
SRCS += $(shell find init/ -name "*.c")
SRCS += $(shell find app/ -name "*.c")
endif

ifeq (greatbelt, $(filter greatbelt, $(chipname)))
SRCS += $(shell find greatbelt/src/    -name "*.c")
CPPFLAGS += -I$(SDK_DIR)/core/greatbelt/include
CPPFLAGS += -I$(SDK_DIR)/core/greatbelt/include/ctc
CPPFLAGS += -I$(SDK_DIR)/core/greatbelt/include/sys
endif

ifeq (goldengate, $(filter goldengate, $(chipname)))
SRCS += $(shell find goldengate/src/    -name "*.c")
CPPFLAGS += -I$(SDK_DIR)/core/goldengate/include
CPPFLAGS += -I$(SDK_DIR)/core/goldengate/include/ctc
CPPFLAGS += -I$(SDK_DIR)/core/goldengate/include/sys
endif

ifeq ($(USW),yes)
SRCS += $(shell find usw/src/sys/ -maxdepth 1 -name "*.c")
SRCS += $(foreach n, $(chipname), $(shell find usw/src/sys/$(n) -name "*.c"))
ifeq (duet2, $(filter duet2, $(chipname)))
SRCS += $(shell find usw/src/ctc_tmx -maxdepth 1 -name "*.c")
endif
ifeq (tsingma, $(filter tsingma, $(chipname)))
SRCS += $(shell find usw/src/ctc_tmx -maxdepth 1 -name "*.c")
SRCS += $(shell find usw/src/sys/duet2 -name "*.c")
endif
ifeq (tsingma_mx, $(filter tsingma_mx, $(chipname)))
SRCS += $(shell find usw/src/ctc_tmx -maxdepth 1 -name "*.c")
SRCS += $(shell find usw/src/sys/duet2 -name "*.c")
SRCS += $(shell find usw/src/sys/tsingma -name "*.c")
endif
ifeq (tsingma_gx, $(filter tsingma_gx, $(chipname)))
SRCS += $(shell find usw/src/ctc_tmx -maxdepth 1 -name "*.c")
SRCS += $(shell find usw/src/sys/duet2 -name "*.c")
SRCS += $(shell find usw/src/sys/tsingma -name "*.c")
SRCS += $(shell find usw/src/sys/tsingma_mx -name "*.c")
endif
ifeq (arctic, $(filter $(chipname), arctic))
SRCS += $(shell find usw/src/ctc_at -maxdepth 1 -name "*.c")
SRCS += $(shell find usw/src/sys/duet2 -name "*.c")
SRCS += $(shell find usw/src/sys/tsingma -name "*.c")
SRCS += $(shell find usw/src/sys/tsingma_mx -name "*.c")
endif
CPPFLAGS += -I$(SDK_DIR)/core/usw/include
CPPFLAGS += -I$(SDK_DIR)/core/usw/include/ctc_tmx
CPPFLAGS += -I$(SDK_DIR)/core/usw/include/ctc_at
CPPFLAGS += -I$(SDK_DIR)/core/usw/include/sys
CPPFLAGS += -I$(SDK_DIR)/driver/api
endif

ifeq ($(ASW),yes)
SRCS += $(foreach n, $(chipname), $(shell find asw/src/$(n) -name "*.c"))
CPPFLAGS += -I$(SDK_DIR)/core/asw/include
endif

CPPFLAGS += -I$(SDK_DIR)/driver
CPPFLAGS += -I$(SDK_DIR)/libctccli/include
CPPFLAGS += -I$(SDK_DIR)/dal/include
CPPFLAGS += -I$(SDK_DIR)/sal/include
CPPFLAGS += -I$(SDK_DIR)/core/api/include
CPPFLAGS += -I$(SDK_DIR)/core/common/include
CPPFLAGS += -I$(SDK_DIR)/core/init
CPPFLAGS += -I$(SDK_DIR)/core


include $(MK_DIR)/lib.mk

endif




ifeq ($(strip $(targetbase)),vxworks)

OBJ_DIR=$(OBJ_BASE_DIR)/core

all_targets = api init common app $(COMPATIBAL_CHIP)
ifeq ($(USW),yes)
all_targets += usw
endif
all_targets += libsdkcore

all: $(all_targets) FORCE
clean: $(addprefix clean_,$(all_targets)) FORCE

api: FORCE
	$(CTC_MAKE) -C $(SDK_DIR)/core/api -f Makefile.vx

clean_api: FORCE
	$(CTC_MAKE) -C $(SDK_DIR)/core/api -f Makefile.vx clean

init: FORCE
	$(CTC_MAKE) -C $(SDK_DIR)/core/init -f Makefile.vx

clean_init: FORCE
	$(CTC_MAKE) -C $(SDK_DIR)/core/init -f Makefile.vx clean

common: FORCE
	$(CTC_MAKE) -C $(SDK_DIR)/core/common -f Makefile.vx

clean_common: FORCE
	$(CTC_MAKE) -C $(SDK_DIR)/core/common -f Makefile.vx clean

app: FORCE
	$(CTC_MAKE) -C $(SDK_DIR)/core/app -f Makefile.vx

clean_app: FORCE
	$(CTC_MAKE) -C $(SDK_DIR)/core/app -f Makefile.vx clean

usw: FORCE
	$(CTC_MAKE) -C $(SDK_DIR)/core/usw -f Makefile.vx

clean_usw: FORCE
	$(CTC_MAKE) -C $(SDK_DIR)/core/usw -f Makefile.vx clean

goldengate: FORCE
	$(CTC_MAKE) -C $(SDK_DIR)/core/goldengate -f Makefile.vx

clean_goldengate: FORCE
	$(CTC_MAKE) -C $(SDK_DIR)/core/goldengate -f Makefile.vx clean

greatbelt: FORCE
	$(CTC_MAKE) -C $(SDK_DIR)/core/greatbelt -f Makefile.vx

clean_greatbelt: FORCE
	$(CTC_MAKE) -C $(SDK_DIR)/core/greatbelt -f Makefile.vx clean

libsdkcore: FORCE
	$(CTC_MAKE) -f Makefile_libsdkcore.vx

clean_libsdkcore: FORCE
	$(CTC_MAKE) -f Makefile_libsdkcore.vx clean

.PHONY: FORCE
FORCE:
endif
